var t = getApp();

Page({
    data: {
        active: "",
        list: [],
        base_data: {},
        sum_settled: "",
        sum_unsettled: "",
        receiveBonus: {},
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        }), this.initData();
    },
    onReady: function() {},
    onShow: function() {
        this.getData();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.getData();
    },
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    onShareTimeline: function() {
        return {
            title: "储备基金"
        };
    },
    onChange: function(t) {
        1 === t.detail.index ? this.setData({
            active: "unsettled"
        }) : 2 === t.detail.index ? this.setData({
            active: "settled"
        }) : 3 === t.detail.index ? this.setData({
            active: "invalid"
        }) : this.setData({
            active: ""
        }), this.initData(), this.getData();
    },
    toUrl: function() {
        var t = this.data.receiveBonus.price, a = this.data.receiveBonus.from_id;
        console.log(a), wx.navigateTo({
            url: "/packageH/reserveFunds/reserveFundsSuccess/reserveFundsSuccess?price=" + t + "&from_id=" + a
        });
    },
    initData: function() {
        this.setData({
            list: [],
            page: 1,
            total_page: 0,
            isLoadMore: !0
        });
    },
    getData: function() {
        var a = this, e = {
            is_type: this.data.active,
            page: 1
        }, s = t.getNetAddresss("plugin.reserve-fund.api.Income.index");
        t._getNetWork({
            url: s,
            data: e,
            success: function(t) {
                var e = t.data;
                1 == e.result ? (a.setData({
                    base_data: e.data.getBonus.member,
                    sum_settled: e.data.getBonus.sum_settled,
                    sum_unsettled: e.data.getBonus.sum_unsettled,
                    list: e.data.getBonus.list.data,
                    total_page: e.data.getBonus.list.last_page,
                    receiveBonus: e.data.getReceiveBonus,
                    isLoadMore: !0
                }), a.data.total_page <= 1 && a.setData({
                    isLoadMore: !1
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var a = this;
        if (this.data.page >= this.data.total_page) a.setData({
            isLoadMore: !1
        }); else {
            a.setData({
                page: this.data.page + 1
            });
            var e = {
                is_type: this.data.active,
                page: this.data.page
            }, s = t.getNetAddresss("plugin.reserve-fund.api.Income.index");
            t._getNetWork({
                url: s,
                data: e,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? a.setData({
                        total_page: e.data.getBonus.list.last_page,
                        list: a.data.list.concat(e.data.getBonus.list.data),
                        isLoadMore: !0
                    }) : a.setData({
                        page: a.data.page - 1,
                        isLoadMore: !1
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    }
});